home *** CD-ROM | disk | FTP | other *** search
/ c't freeware shareware 2001 January / CT_SW0101.ISO / mac / software / betrieb / menue / cmscript.sit / CMScript 1.3.3 / ReadMe next >
Text File  |  1999-03-24  |  12KB  |  214 lines

  1. CMScript
  2. © Michael Schürig 1998, 1999
  3.  
  4.  
  5. CMScript is a Contextual Menu Plugin that runs AppleScripts on the "context".
  6.  
  7. CMScript will not stay a separate product until the end of time. Plans are that it will be integrated with a future version of Leonard Rosenthol's "OSA Menu" (see <http://www.lazerware.com/~leonardr/>).
  8.  
  9. Starting with version 1.2 CMScript has absorbed my Word Services plugin. Look for info in the separate document "Using Word Services".
  10.  
  11.  
  12. What's new?
  13.  
  14. Version 1.3 adds support for Mac OS 8.5, meaning that it now uses the Scripts folder inside the System Folder as the top-most folder for scripts. This has required a slight change to how contexts are handled: Now scripts that don't specify a desired context are ignored.
  15.  
  16. Finally, you can specify multiple desired contexts that a script applies to. Put each 
  17. desired context specification on its own line in the script's description. 
  18. Separate the context specifications with a blank line from any further text 
  19. inside the script's description. (Note: a line containing space characters 
  20. is not considered blank.)
  21.  
  22.  
  23. Installation
  24.  
  25. Put the two plugins, CMScript and ContextGrabber, into the Contextual Menu Items folder inside the System Folder. Move the contents of -> System Folder:-> Scripts: into the Scripts folder inside the System Folder.
  26.  
  27. Alternatively, you can put the the CMScript's folders into a Contextual Menu Scripts sub-folder inside the Scripts folder. This can be useful to avoid conflict with other pieces of software that use the Scripts folder.
  28.  
  29.  
  30. What it does
  31.  
  32. What does it do with the scripts in the Scripts folder? 
  33. Wherever you are CMScript takes into account scripts found in two subfolders: Universal Scripts and Application Name Scripts (e.g. Finder Scripts, Internet Explorer 4.0 Scripts). For applications that don't have a folder of their own, CMScript looks for scripts inside the Other Scripts folder.
  34.  
  35. BTW, you can nest folders inside the script folders. The depth is arbitrarily restricted to three levels. Also you can use aliases to scripts instead of actual scripts.
  36.  
  37. When you activate the Contextual Menu  by holding down the control key and clicking the mouse CMScript scans these folders for scripts. For each found script it checks if it applies to the context.
  38.  
  39.  
  40. How it works (technically — skip if you like)
  41.  
  42. To facilitate finding out if a script applies to the context scripts must tell what kind of data they understand: the first paragraph of the script's description is used for this purpose. Put the type code of the data your script can operate on there. CMScript determines if the context can be made into the desired data type or a list of items of that type. If you want your script to be applicable in multiple different contexts, you can use multiple lines.
  43.  
  44. If you want to use the description field for its original purpose, i.e. description of the script, put a blank line after the context specification lines. (Lines containing space characters are not considered blank.)
  45.  
  46. More complex context specifications:
  47.  
  48. fss TEXTttxt    - only SimpleText text documents
  49. fss TEXT        - any text document
  50. fss ****ttxt    - any SimpleText document
  51.  
  52. reco            - any record
  53. recopnme        - a record containing a name (= «class pnam») property and possibly others.
  54. recopnamldt     - ditto + a date (= «class ldt ») property.
  55.  
  56. ****            - any context, except an empty one
  57. null            - any context, including an empty one
  58.  
  59. You can check for "object specifiers" (sorry for the jargon):
  60.  
  61. obj cfol        - folders (only in the Finder)
  62.  
  63. And finally, of course, you can check for any old type, say text:
  64.  
  65. TEXT            - anything that can be made into text
  66. TEXT!           - only text
  67.  
  68. If a script is applicable to the context its filename is put into the CM. When a script is chosen from the CM its open-handler gets called with the context data as a list (possibly having only one element) of items of the desired type.
  69.  
  70.  
  71. How do I find out what the context is?
  72.  
  73. Now, the description above may have been just a bit too technical. Here's the easy way. :-)
  74.  
  75. Use the included ContextGrabber Module to find out about the context:
  76.  
  77. If caps lock is pressed during a context-click ContextGrabber does several things:
  78.  
  79. • It adds a menu item Make Template Script. This command puts a script file on your desktop that's already preconfigured somewhat to be useful in the currently selected context. Remember to save it as a compiled script if you want to use it from the CMScript!
  80.  
  81. • It adds an item to Copy Context to Clipboard with the submenu items Easy and Advanced.
  82.  
  83. Advanced is only suited for hardcore AppleEvent freaks, they'll get output from AEPrint (and understand what this means for them). 
  84.  
  85. Easy is something suitable for use as a desired context (first line of the script's description) in your own scripts. One special case is that this plugin does not take file objects to be objects, i.e. "obj file", but treats them as file specifications. Thus you'd get the more helpful "fss TEXTttxt" if you selected a SimpleText text document.
  86.  
  87.  
  88. Changing the order of scripts in the menu
  89.  
  90. You can determine the order of scripts in the contextual menu by following these conventions:
  91.  
  92. Generally scripts are alphabetically ordered, but if a script's or a folder's name starts with "xx)" (where "x" can be anything except "(") this prefix is not shown in the menu.
  93.  
  94. Nested script folders whose names end with "-!!X" are ignored.
  95.  
  96. Files or folders whose name ends with "-***" generate a separator line in the context menu. CMScript tries to be smart about separators and avoids to add multiple adjacent ones. (By convention it is not possible to add a separator as the last item. Basically a plugin is allowed to separate itself from what comes before it, but not from what comes after it.) 
  97.  
  98.  
  99. Questions & Answers
  100.  
  101. Q. Why don't the installed plugins show up in the Contextual Menu?
  102. A: The most common reason is that you tried to be smart some time ago and disabled SOMobjects™ for Mac OS. Don't do that! Contextual Menu Plugins don't work without it. And beside that it does nothing bad to your system: It is a so-called shared library that does absolutely nothing unless used by an application, extension, or plugin.
  103.  
  104.  
  105. Q: Why do I see the Contextual Menu only in the Finder?
  106. A: Well, the reason is that only very few applications actually support the Contextual Menu yet. But you can get around this by installing Apple Data Detectors (look for it on <http://applescript.apple.com>). Among other things this will give you the Contextual Menu Enabler extension that will enable the contextual menu in virtually any application.
  107.  
  108.  
  109. Q: My script doesn't work. How do I find out what's happening?
  110. A: The easiest way is to run the script inside your Script Editor.
  111.  
  112. Add the following lines to your script. Of course you need to replace "Finder" with the name of the application where you intend to use the script.
  113.  
  114. tell application "Finder" to set sel to (the selection) as list
  115. open (sel)
  116.  
  117. From the Controls menu choose Open Event Log and enable both Show Events and Show Event Results. This will give you a detailed log of what's happening in the script.
  118.  
  119. Unfortunately this method won't work with applications that do not have reasonable scripting support. And there may be cases where you have to test your script under the actual conditions of its use. But there's still hope:
  120.  
  121. Use Message Window application to display information about your script's progress. (see <http://T3.acmetech.com/acme/files/freebies/MessageWin.hqx>)
  122.  
  123. Use the show variables command from Ed Lai’s programmer's tool Scripting Addition to display the value of a variable in a dialog box. (see <http://www.scriptweb.com/osaxen/programmers_tool.html>).
  124.  
  125.  
  126. Q: I've added scripts to one of the scripts folders, but they don't show up in the menu even though they really should.
  127. A: Run the included Update CMScripts application. If that still doesn't work, do something that changes the modification date of the Scripts folder. One way to do this is to move a contained folder out of the Scripts folder and then put it back in.
  128.  
  129.  
  130. Q: How do I find the actual class of the object(s) that was clicked?
  131. A: Given that the application your context script is working in supports AppleScript sensibly do it like this:
  132.  
  133. on open
  134.        tell application "Finder"
  135.               set theSelection to the selection
  136.               try
  137.                      repeat with theItem in theSelection
  138.                             -- put your script here
  139.                      end repeat
  140.               on error errMsg
  141.                      display dialog errMsg buttons {"OK"} default button 1
  142.               end try
  143.        end tell
  144. end open
  145.  
  146.  
  147. Q: How do I switch to another application from a script?
  148. A: Don't! And it's good if you can't as you might seriously confuse the frontmost app to be surreptitiously switched to the background.
  149. That said, there's still a clean way to do it. Look at the Switch script and the Switcheroo script application for an example.
  150.  
  151.  
  152. Q: When I run a script that takes a long time to execute my Mac is blocked. What can I do?
  153. A: Write your script in two parts:
  154. A script application that does the actual work and a script that triggers that application from the contextual menu. Look at the Speak it! script and the Text Speaker script application for an example.
  155.  
  156.  
  157. Q: Those scripts keep asking me where application "Switcheroo", "Speak it!", … is. What can I do?
  158. A: Open the offending script in the Script Editor. Change it slightly, add a blank at the end, say, and then save it again. Now you will be asked to find the applications used by the script—and then you won't be asked again if all goes well.
  159.  
  160.  
  161. Proper use of the Contextual Menu
  162.  
  163. "Your plugin only shows 11 of the 25 scripts in my Universal Scripts folder." Well, chances are that you're abusing the Contextual Menu. As its name says it is a contextual menu, one that ought to show what can be done in the context at hand. If you put a lot of general stuff in there, be prepared for problems of the kind you're experiencing: The menu is slow to appear and there are items missing. 
  164.  
  165.  
  166. In case of trouble
  167.  
  168. • Make sure only one Contextual Menu Extension is installed. This can be a problem in particular on non-US systems as some software installers may install a duplicate US-copy on such a system (a case in point apparently is/was Apple Data Detectors).
  169.  
  170. Please tell me about your problems so I can do something about them or add them here.
  171.  
  172.  
  173. If you've written a cool script…
  174.  
  175. …please send me a copy. I'll consider it for inclusion with a future version of CMScript or maybe a separate "Service Pack".
  176.  
  177.  
  178. Version History
  179.  
  180. The current version is always available from my home page (see below). Also, I'll submit new versions to the info-mac archive.
  181.  
  182. 1.3.3  Folder names using "xx)" prefixes no appear correctly.
  183. 1.3.2  Fixes a newly introduced bug that prevented CMScript from working on systems prior to 8.5
  184. 1.3.1  By popular demand allows for the nested "Contextual Menu Scripts" folder.
  185.           Doesn't report "User Canceled" errors that escape from scripts.
  186. 1.3     Fixes a bug that prevented CMScript from working on systems prior to 8.5
  187. 1.3b2 Support for multiple desired contexts
  188. 1.3b1 Look for scripts in System Folder:Scripts.
  189.           Scripts that don't specifiy a desired context are ignored!
  190.           Removed one bug triggered by folders containing only non-scripts. 
  191. 1.2     No relevant changes.
  192. 1.2b1 Integrated Word Services CM.
  193. 1.1b1 Faster menu creation. "Other Scripts" folder. Improved template script.
  194. 1.0.6  Improved ordering of scripts.
  195. 1.0.5  'obj ' context are now recognized correctly. (Thanks to Jens Miltner.)
  196.           Slight twiddling of memory handling.
  197. 1.0.4  Fixed a hierarchical menu handling bug. (Thanks to Lindsey Dubb for spotting it.)
  198. 1.0.3  Added "!" to specify strict checking for arbitrary types.
  199. 1.0.2  Added special treatment of record specifiers in context description.
  200. 1.0.1  First public version.
  201. 1.0     Not released.
  202.  
  203.  
  204. Disclaimer
  205.  
  206. You might have guessed it already, but I take no responsibility for the consequences of anything CMScript does to your computer. If you think this is unacceptable, just don't use it.
  207.  
  208.  
  209. That's it for now. I appreciate any bug reports and suggestions. Have as much fun with this thingie as possible.
  210.  
  211.  
  212. Michael Schürig
  213. <mailto:schuerig@acm.org?Subject=[CMScript]>
  214. <http://www.schuerig.de/michael/>